import { Controller, Get, Req, Post, Body, HttpStatus, HttpException, SetMetadata, UseGuards, UseFilters, ForbiddenException, Param } from '@nestjs/common';
import { Request } from 'express';
import { HttpExceptionFilter } from '../../filters/exception/http-exception.filter';
import { ValidatePipe } from '../../pipes/validate.pipe'

import { User } from './user.interface';
import { UserService } from './user.service';
// dto
import { CreateUserDto } from './dto/create-user.dto';
// import { RolesGuard } from 'src/guard/roles.guard';
import { AuthGuard } from '@nestjs/passport';
import { GetUserDto } from './dto/get-user.dto';


@Controller('user')
// @UseGuards(AuthGuard('jwt'))
export class UserController {
    constructor(private userService: UserService){}

    @Post('createUser')
    // @UseFilters(new HttpExceptionFilter())
    async create(@Body() createUserDto: CreateUserDto) {
        // throw new ForbiddenException();
        this.userService.create(createUserDto);
    }

    @Post('getUser')
    async get(@Body() getUserDto: GetUserDto) {
        return this.userService.findUser(getUserDto);
    }

    @Get()
    async findAll(): Promise<User[]> {
        return this.userService.findAll();
    }

    @Get(':id')
    async remove(@Param() params): Promise<void> {
        await this.userService.remove(params.id);
    }
}
